﻿using Microsoft.Practices.Unity;
using TSharp.Core.Osgi;
using TSharp.Core.Osgi.Internal;

namespace TSharp.Core.Unity
{
	partial class UnityServiceSituation
	{

        private static readonly object synroot = new object();
   
        private static UnityLocatorWrapper _rootContainer;

        private IUnityContainer CreateRootContainer()
        {
            log.Debug("创建 root");

            IUnityContainer container = new UnityContainer();

            UnitySection.Configure(container, CONFIG_CONTAINER_NAME_SYSTEM);

            Configure(ServiceManager.RootMap, container);
            return container;
        }


        private UnityLocatorWrapper GetOrCreateRootWrapper()
        {
            if (_rootContainer != null)
                return _rootContainer;
            lock (synroot)
            {
                if (_rootContainer == null)
                    _rootContainer = new UnityLocatorWrapper(CreateRootContainer(), Level.ROOT);
                return _rootContainer;
            }
        }
       
 

 

	}
}